object Homework1 {

  def main(args: Array[String]): Unit = {

    val num = 100 / 2;
    val i = GetBottleNumber(cap=num, empty = num, bottle = 0)
    println("最多能喝的啤酒数:"+(num+i))
  }

  def GetBottleNumber(cap: Int, empty: Int, bottle: Int): Int = {
    if (empty < 3 && cap < 5) {
      bottle
    }else{
      // 空瓶可以换的啤酒数
      val a: Int = empty / 3
      // 换完以后，空瓶数
      val b: Int = empty % 3
      // 瓶盖可以换的啤酒数
      val c: Int = cap / 5
      //换完以后的瓶盖数
      val d: Int = cap % 5
      printf("cap = %d,empty = %d,bottle = %d\n",a+c+d,a+c+b,a+c+bottle);
      GetBottleNumber(a + c + d, a + c + b, a + c + bottle)
    }
  }
}
